<include file="Public/head"/>

<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="cf">
                            <form class="form-inline" action="" method="get">
                                <label class="inline">驾照类型</label>
                                    <select name="l_type" id="l_type" class="form-control">
                                        <option value="">--请选择驾照类型--</option>
                                            <volist name="license_type" id="val">
                                                <option value="{$val['id']}" <if condition="$val['id'] eq I('get.l_type')">selected="selected"</if>>{$val['type']}</option>
                                            </volist>
                                    </select>
                                    <label class="inline">班型</label>
                                    <select name="c_id" id="c_id" class="form-control">
                                        <option value="">--请选择班级--</option>
                                    </select>
                                    <label class="inline">是否已缴费</label>
                                    <select name="is_paid" id="is_paid" class="form-control">
                                        <option value="n">--请选择支付状态--</option>
                                        <!-- <option value="0" <if condition="I('get.is_paid') eq 0">selected="selected"</if>>未付款</option>
                                        <option value="1" <if condition="I('get.is_paid') eq 1">selected="selected"</if>>已付款</option> -->
                                        <option value="0">未付款</option>
                                        <option value="1">已付款</option>
                                    </select>
                                <button type="button" onclick="sou()" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                                <button type="button" onClick="dayin()" class="btn btn-purple btn-sm">
                                    <span class="ace-icon   icon-on-right bigger-110"></span>
                                    打印
                                </button>
                            </form>
                        </div>
                    <div class="space-4"></div>
                    <form id="form" method="post" action="{:U('del')}">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                <th>驾校</th>
                                <th>用户</th>
                                <th>身份证号</th>
                                <th>手机</th>
                                <th>驾照</th>
                                <th>班型</th>
                                <th>价格</th>
                                <th>是否已付款</th>
                                <th>付款方式</th>
                                <th>付款时间</th>
                                <th>报名时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <foreach name="list" item="val">
                                <tr>
                                    <td class="center">
                                        <input class="comments"
                                               type="checkbox"
                                               name="id[]"
                                               value="{$val['id']}">
                                    </td>
                                    <td>{$val['school_name']}</td>
                                    <td>{$val['user_name']}</td>
                                    <td>{$val['id_card']}</td>
                                    <td>{$val['phone']}</td>
                                    <td>{$val['type']}</td>
                                    <td>{$val['class_name']}</td>
                                    <td>￥&nbsp;{$val['money']}</td>
                                    <!--<td>{$val['is_paid']}</td>-->
                                    <if condition="$val['is_paid'] eq 0">
                                        <td>未付款</td>
                                        <elseif condition="$val['is_paid'] eq 1"/>
                                        <td>已付款</td>
                                    </if>
                                    <if condition="$val['pay_way'] eq 1">
                                        <td>线上支付</td>
                                        <else/>
                                        <td>线下支付</td>
                                    </if>
                                    <if condition="$val['pay_time'] eq null">
                                        <td>--</td>
                                        <elseif condition="$val['is_paid'] eq 1"/>
                                        <td>{$val['pay_time']|date="Y-m-d H:i:s",###}</td>
                                    </if>
                                        <td>{$val['add_time']|date="Y-m-d H:i:s",###}</td>


                                    <td><a href="javascript:;" val="{:U('del',array('id'=>$val['id']))}" class="del"><i
                                                class="ace-icon fa fa-trash-o bigger-100 red"></i>&nbsp;删除</a></td>
                                </tr>
                            </foreach>
                            <if condition="$list eq null"><tr><td colspan="13" align="center">没有数据！</td></tr></if>
                            </tbody>
                        </table>
                    </form>
                    <div class="cf">
                        <input id="submit" class="btn btn-info" type="button" value="删除">
                    </div>
                    {$page}
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>
</div><!-- /.main-content -->
<include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".check-all").click(function () {
            $(".comments").prop("checked", this.checked);
        });
        $(".comments").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除此类驾照？？",
                callback: function (result) {
                    if (result) {
                        $("#form").submit();
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除此类驾照？",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });

        var l_type = $('#l_type').val();
        $.ajax({
            url: "{:U('Sign/getClassLevel')}",
            type: 'post',
            dataType: 'json',
            data: {'l_type': l_type},
            success : function (res){
               if(res.res == 1){
                  var data = res.data;
                  var str = '<option value="">--请选择班级--</option>';
                    var c_id = "{:I('c_id')}";
                  for (var i = 0; i < data.length; i++) {
                    if(c_id == data[i]['id']){
                       str += '<option selected="selected" value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
                    }else{
                        str += '<option value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
                    }
                  }
                  $('#c_id').html();
                  $('#c_id').html(str);
               }            
           }
        });
    })

//搜索
$('#l_type').change(
    function(event) {
        var l_type = $('#l_type').val();
        $.ajax({
            url: "{:U('Sign/getClassLevel')}",
            type: 'post',
            dataType: 'json',
            data: {'l_type': l_type},
            success : function (res){
               if(res.res == 1){
                  var data = res.data;
                  var str = '<option value="">--请选择班级--</option>';
                  var c_id = "{:I('c_id')}";
                  for (var i = 0; i < data.length; i++) {
                     if(c_id == data[i]['id']){
                       str += '<option selected="selected" value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
                    }else{
                        str += '<option value="'+data[i]['id']+'">'+data[i]['name']+'</option>';
                    }
                  }
                  $('#c_id').html();
                  $('#c_id').html(str);
               }            
           }
        })
        
});

function sou(){
    l_type = $('#l_type').val();
    c_id = $('#c_id').val();
    is_paid = $('#is_paid').val();
    var param = '';
    if(c_id){
        param += '/c_id/'+c_id; 
    }
    if(l_type){
        param += '/l_type/'+l_type;
    }
    if(is_paid !=='n'){
        param += '/is_paid/'+is_paid;
    }
    location.href="__APP__/Admin/Sign/index"+param+".html";
}
function dayin(){ 
    location.href='__APP__/Admin/Sign/dayin.html';
}
</script>
</body>
</html>
